package com.zrrd.spring_03_annotation;

import com.zrrd.spring_03_annotation.config.SpringConfig;
import com.zrrd.spring_03_annotation.mapper.TeaDao;
import com.zrrd.spring_03_annotation.service.TeaService;
import com.zrrd.spring_03_annotation.service.UserService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author WanJl
 * @version 1.0
 * @title Main
 * @description
 * @create 2024/10/27
 */
public class Main {
    public static void main(String[] args) {
        //ClassPathXmlApplicationContext context =
        //        new ClassPathXmlApplicationContext("applicationContext.xml");
        //注解配置应用程序上下文：以注解的方式配置spring的核心配置。
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        context.registerShutdownHook();
//        TeaDao teaDao = context.getBean(TeaDao.class);
//        teaDao.teaDaoMethod();
//
//        TeaService teaService = context.getBean("teaServiceImpl",TeaService.class);
//        teaService.method();
        UserService userService = context.getBean(UserService.class);
        userService.sayHello();
    }
}
